<?php


namespace app\api\library\login\sendMsg;


use app\api\help\SendMsg;
use think\facade\Db;

class V
{
    public static function run($param)
    {
        $mobile = $param[ 'mobile' ];
        //发送验证码
        $msg[ 'code' ] = mt_rand(100000, 999999);
        $ret           = SendMsg::sendMsg($mobile, $msg, 'SMS_460890222');
        if (false === $ret) {
            _outPut(306, $ret);
        }
        //验证码入DB
        $data = [
            'mobile'      => $mobile,
            'code'        => $msg[ 'code' ],
            'create_time' => time(),
            'expire_time' => time() + 120,
        ];
        if (false === Db::name('mall_mobile_msg')->insert($data)) {
            _outPut(204);
        }
        _output(200, $msg[ 'code' ]);
    }
}